﻿<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="PaymentHistoryListCtrl.ascx.cs" Inherits="WebUI.Controls.PaymentHistoryListCtrl" %>


<script type="text/javascript">
    var <%=ClientID %>clickOnCheckbox;
    var <%=ClientID %>selectedRow = null;       
    var <%=ClientID %>selectedCheckbox = null; 
    var <%=ClientID %>selectedID = null; 
    var <%=ClientID %>selectedClass = null; 
    
    function resetGridSelection<%=ClientID %>(){
        <%=ClientID %>selectedRow = null;   
        if(<%=ClientID %>selectedCheckbox != null)
            <%=ClientID %>selectedCheckbox.checked = false;          
        <%=ClientID %>selectedCheckbox = null; 
        <%=ClientID %>selectedID = null; 
        <%=ClientID %>selectedClass = null; 
    }
    
    function clickOnCheckBox<%=ClientID %>(cb){
        <%=ClientID %>clickOnCheckbox = true;
    }
    
    function onItemClick<%=ClientID %>(sender)
    {
        if(<%=ClientID %>clickOnCheckbox){
            <%=ClientID %>clickOnCheckbox = false;
            return;
        }
        
        if(<%=ClientID %>selectedRow != null){
            if(<%=ClientID %>selectedRow.className)
                <%=ClientID %>selectedRow.className = <%=ClientID %>selectedClass;
            else
                <%=ClientID %>selectedRow.setAttribute("class", <%=ClientID %>selectedClass);
            if(<%=ClientID %>selectedCheckbox != null)
                <%=ClientID %>selectedCheckbox.checked = false;
        }
        
        if(sender.className){
            <%=ClientID %>selectedClass = sender.className;
            sender.className = "CustomGridSelectedItem";
        }
        else{
            <%=ClientID %>selectedClass = sender.getAttribute("class");
            sender.setAttribute("class", "CustomGridSelectedItem");
        }
        <%=ClientID %>selectedRow = sender;
        
        var inputs = sender.getElementsByTagName("input");
        for(var i = 0; i < inputs.length; i++){
            if(inputs[i].type == "checkbox" && inputs[i].id.indexOf("cbSelect") >= 0){
                <%=ClientID %>selectedCheckbox = inputs[i];
                inputs[i].checked = true;
                break;
            }
        }
        
        <%=ClientID %>selectedID = <%=ClientID %>selectedRow.getAttribute("ItemID");
    }
    
    function selectAll<%=ClientID %>(cbAll){
        var grid = document.getElementById("<%=grid.ClientID %>");
        var inputs = grid.getElementsByTagName("input");
        for(var i = 0; i < inputs.length; i++){
            if(inputs[i].type == "checkbox"){
                inputs[i].checked = cbAll.checked;
            }
        }
    }
    
    function getSelectedItemID<%=ClientID %>()
    {
        return <%=ClientID %>selectedID;
    }
    
    function showPrintDlg(key) {
        var returnValue = window.showModalDialog(key, '', 'dialogWidth=800px;dialogHeight=600px;resizable=yes;help=no;unadorned=yes;');
    }
    
    function onInvoiceNo_click(lnk)
    {
        var hidInvoiceID = document.getElementById("<%= hidInvoiceID.ClientID %>");     
        hidInvoiceID.value = lnk.getAttribute('ItemID');
    }
</script>

<%--start modify here--%>


    
    <asp:DataGrid ID="grid" runat="server" AllowPaging="true" AllowSorting="true" GridLines="None" class="customGrid" ShowFooter="true"
    AutoGenerateColumns="false" EmptyDataText="No record to display" ItemStyle-Wrap="true" CellPadding="1" CellSpacing="1"
    OnSortCommand="grid_OnSortCommand" OnItemCreated="grid_OnItemCreated" OnItemDataBound="grid_OnItemDataBound"
    OnPageIndexChanged="grid_OnPageIndexChanged" AllowCustomPaging="true" UseAccessibleHeader="true" DataKeyField="ID">
    <PagerStyle Mode="NumericPages" PageButtonCount="10"   />
    <Columns>
        <asp:TemplateColumn ItemStyle-Width="20px" HeaderStyle-Width="20px" ItemStyle-HorizontalAlign="Center" HeaderStyle-HorizontalAlign="Center">
            <HeaderTemplate><asp:CheckBox ID="cbSelectAll" runat="server" /></HeaderTemplate>
            <ItemTemplate>
                <asp:CheckBox ID="cbSelect" runat="server" ItemID='<%# Eval("ID") %>' />
            </ItemTemplate>
        </asp:TemplateColumn>
        <%--start modify here--%>
        <asp:BoundColumn ItemStyle-HorizontalAlign="Left" HeaderStyle-HorizontalAlign="Left" ItemStyle-Width="150px" DataField="ID" SortExpression="ID" HeaderText="ID" Visible="false"></asp:BoundColumn>
        <%--<asp:BoundColumn ItemStyle-HorizontalAlign="Left" HeaderStyle-HorizontalAlign="Left" ItemStyle-Width="150px" DataField="PaidDate" SortExpression="PaidDate" HeaderText="Date" Visible="true"></asp:BoundColumn>
        --%>
        <asp:TemplateColumn ItemStyle-HorizontalAlign="Left" HeaderStyle-HorizontalAlign="Left"
            ItemStyle-Width="100px" SortExpression="PaidDate" HeaderText="Date" Visible="true">
            <ItemTemplate>
                <asp:Label ID="lblDate" runat="server" Text='<%# ((DateTime)Eval("PaidDate")).ToString(POSSystem.BLL.SystemVariables.SysVars.DateFormat) %>'></asp:Label>
            </ItemTemplate>
        </asp:TemplateColumn>

        <asp:TemplateColumn HeaderText="InvoiceNo" ItemStyle-Width="80px">
            <ItemTemplate>
                <asp:LinkButton ID="lnkInvoiceNo" runat="server" Text='<%# Eval("InvoiceNo") %>' OnClientClick='onInvoiceNo_click(this); return true;' OnClick="btnPrint_OnClick" ItemID='<%# Eval("InvoiceID") %>'></asp:LinkButton>
            </ItemTemplate>
        </asp:TemplateColumn>
        
        <asp:BoundColumn ItemStyle-HorizontalAlign="Left" HeaderStyle-HorizontalAlign="Left" ItemStyle-Width="150px" DataField="PaymentMethodDesc" SortExpression="PaymentMethodDesc" HeaderText="Payment Method" Visible="true"></asp:BoundColumn>
        <asp:BoundColumn ItemStyle-HorizontalAlign="Left" HeaderStyle-HorizontalAlign="Left" ItemStyle-Width="60px" DataField="PaidAmount" SortExpression="PaidAmount" HeaderText="Paid" Visible="true"></asp:BoundColumn>
        <asp:BoundColumn ItemStyle-HorizontalAlign="Left" HeaderStyle-HorizontalAlign="Left" ItemStyle-Width="100px" DataField="SaleUserFullName" SortExpression="SaleUserFullName" HeaderText="Sale Person" Visible="true"></asp:BoundColumn>
    </Columns>
</asp:DataGrid>
<asp:HiddenField ID="hidInvoiceID" runat="server" />
<asp:HiddenField ID="hidSelectedID" runat="server" />